package com.terabits.smartriver.meta.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.terabits.smartriver.constants.DeviceEnum;

import java.util.Date;
import java.util.List;

/**
 * Created by Yin on 2019/3/18
 * 保养VO
 */
public class MaintenanceVO {
    private Integer maintenanceId;
    private String deviceNum;
    private String project;
    /**
     * 设备名称
     */
    private String deviceName;

    /**
     * 设备位置
     */
    private String position;

    private String realname;
    /**
     * 0未解决 1已解决
     */
    private Integer result;
    /**
     * 保养时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date timeCreate;
    /**
     * 最后修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date timeUpdate;
    /**
     * 当前状态
     */
    private String currentState;

    private List<MaintenanceDetailVO> details;

    public Integer getMaintenanceId() {
        return maintenanceId;
    }

    public void setMaintenanceId(Integer maintenanceId) {
        this.maintenanceId = maintenanceId;
    }

    public String getDeviceNum() {
        return deviceNum;
    }

    public void setDeviceNum(String deviceNum) {
        this.deviceNum = deviceNum;
    }

    public String getProject() {
        return project;
    }

    public void setProject(String project) {
        this.project = project;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getRealname() {
        realname = this.details.get(0).getRealname();
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public Integer getResult() {
        return result;
    }

    public void setResult(Integer result) {
        this.result = result;
    }

    public Date getTimeCreate() {
        return timeCreate;
    }

    public void setTimeCreate(Date timeCreate) {
        this.timeCreate = timeCreate;
    }

    public Date getTimeUpdate() {
        return timeUpdate;
    }

    public void setTimeUpdate(Date timeUpdate) {
        this.timeUpdate = timeUpdate;
    }

    public String getCurrentState() {
        if (getResult() == 1) {
            return currentState = "已完毕";
        } else {
            if (DeviceEnum.MAINTENANCE_TYPE_M.getType().equals(getDetails().get(getDetails().size() - 1).getType())) {
                return currentState = "待检查";
            } else {
                return currentState = "待重新保养";
            }
        }
    }

    public void setCurrentState(String currentState) {
        this.currentState = currentState;
    }

    public List<MaintenanceDetailVO> getDetails() {
        return details;
    }

    public void setDetails(List<MaintenanceDetailVO> details) {
        this.details = details;
    }
}
